{{template "base/base.html" .}}
{{define "head"}}<title>Go Walker - {{i18n .Lang "Go API documentation and source code view"}}</title>{{end}}
{{define "body"}}
<div>
	{{template "base/alert.html" .}}
    <div class="page-header">
        <h2>
            <b>{{i18n .Lang "Search Go projects"}}</b>.
            <small>{{i18n .Lang "Find a cup of source code"}}.</small>
            <g:plusone></g:plusone>
        </h2>

   		<form class="form-inline search-from" action="/">
    		<div class="form-group col-md-6 main-search">
            	<input autocomplete="off" class="typeahead form-control" type="text" placeholder="{{i18n .Lang "Type import path to add and view or use keywords to search"}}" name="q">
            </div>
            <button class="btn btn-success btn-lg btn-search" type="submit"><i class="icon-search"></i> {{i18n .Lang "I'm feeling lucky"}}</button>
    	</form>
    </div>
</div>

<div class="row">
	<div class="col-xs-8 col-md-8">
		<div>
            {{if eq .Lang "en-US"}}
			<h4><b>What is this?</b></h4>
			<p>
				Go Walker is a web server that generates <a target="_blank" href="http://golang.org/">Go</a> projects API documentation and
				<button class="btn-default feature" title=""
				        data-content="Hacker view provides source file based project code view for Go Standard Library, Go Subrepo and command line project."
				        data-placement="top" data-toggle="popover" data-original-title="Hacker View">Hacker View</button>
				on the fly for the projects on <b><a target="_blank" href="https://bitbucket.org/">Bitbucket</a></b>, <b><a target="_blank" href="https://github.com/">GitHub</a></b>, <b><a target="_blank" href="http://code.google.com/">Google Code</a></b>, <b><a target="_blank" href="https://launchpad.net/">Launchpad</a></b> and <b><a target="_blank" href="http://git.oschina.net/">Git @ OSC</a></b>.
			</p>

			<p>
				Awesome features
                <button class="btn-default feature" title=""
                        data-content="View function and method code with nice highlight in the same page, reduce rake up space and do more work at the same time."
                        data-placement="bottom" data-toggle="popover" data-original-title="Code View">Code View</button>

                <button class="btn-default feature" title=""
                        data-content="Quick jump to functions, methods and types from imported packages, reduce time to find."
                        data-placement="top" data-toggle="popover" data-original-title="Link Jump">Link Jump</button>

                <button class="btn-default feature" title=""
                        data-content="Add examples for your favorite projects through Github Gist." data-placement="bottom"
                        data-toggle="popover" data-original-title="Add Example">Add Example</button>

                <button class="btn-default feature" title=""
                        data-content="Don't worry if you use old version of a project, now you can view documentation by its Tags!"
                        data-placement="right" data-toggle="popover" data-original-title="View by Tag">Doc Tag</button>

                and <a href="/about">More</a>.
			</p>

            <p class="text-success">
                Please read the <a href="/about">About Page</a> for information about hacking with Go Walker and more.
            </p>
            {{else if eq .Lang "zh-CN"}}
            <h4><b>超凡体验，您值得拥有.</b></h4>
            <p>
                Go Walker 是一个可以在线生成并浏览 <a target="_blank" href="http://docs.studygolang.com/">Go</a> 项目 API 文档及
                <button class="btn-default feature" title=""
                        data-content="黑客视图允许您对 Go 标准库、Go 官方维护库和命令行项目进行基于源文件的浏览。"
                        data-placement="top" data-toggle="popover" data-original-title="黑客视图">黑客视图</button>
                的 Web 服务器，目前已支持包括 <b><a target="_blank" href="https://bitbucket.org/">Bitbucket</a></b>、<b><a target="_blank" href="https://github.com/">GitHub</a></b>、<b><a target="_blank" href="http://code.google.com/">Google Code</a></b>、<b><a target="_blank" href="https://launchpad.net/">Launchpad</a></b> 和 <b><a target="_blank" href="http://git.oschina.net/">Git @ OSC</a></b> 在内的五大代码托管平台。
            </p>

            <p>
                经典绝伦的特性包括
                <button class="btn-default feature" title="" data-content="在相同页面快速查看高亮渲染后的函数或方法的代码，减少页面占用，可以同时做更多的工作。" data-placement="bottom" data-toggle="popover" data-original-title="查看代码">查看代码</button>

                <button class="btn-default feature" title="" data-content="快速跳转至函数、方法或类型所以在项目的文档页面，节省您的宝贵时间。" data-placement="top" data-toggle="popover" data-original-title="链接跳转">链接跳转</button>

                <button class="btn-default feature" title="" data-content="通过 Github Gist 来为您喜爱的文档添加示例，更好地展示给更多人。" data-placement="bottom" data-toggle="popover" data-original-title="增加示例">增加示例</button>

                <button class="btn-default feature" title="" data-content="不必再为使用旧版的库而烦恼，现在您可以查看任意 Tag 版本的项目文档喔！" data-placement="right" data-toggle="popover" data-original-title="文档标签">文档标签</button>

                以及 <a href="/about">更多</a>。
            </p>
            
            <p class="text-success">
                如果您想了解如何更好地提升 Go Walker 操作体验及更多，请仔细阅读  <a href="/about">关于</a> 页面。
            </p>
            {{end}}
		</div>
        
        {{$newLine := str2html "\n"}}
        {{$lang := .Lang}}
		<div class="tab-content">
		    <div id="global_history" class="tab-pane fade active in">
		        <h4>
		            <b>{{i18n .Lang "What all the people are looking at"}}</b>.
		            <a href="#user_history" class="btn btn-inverse" data-toggle="tab">{{i18n .Lang "Local history"}}</a>
		            <small class="text-info">{{i18n .Lang "Hover link to see more"}}.</small>
		        </h4>

		        <table name="recent_table" class="table table-bordered table-hover">
		            <thead>
		                <tr>
		                    <th>{{i18n .Lang "Import Path"}}</th>
		                    <th>{{i18n .Lang "Viewd Time(Local)"}}</th>
		                </tr>
		            </thead>
                    
		            <tbody>
			            {{range .GlobalHistory}}
                        <tr>
                            <td>
                                <a title="{{i18n $lang "Refs"}}: {{.RefNum}}  {{i18n $lang "Rank"}}: {{.Rank}}  {{i18n $lang "Views"}}: {{.Views}}{{$newLine}}{{i18n $lang "Issues"}}: {{.Issues}}  {{i18n $lang "Stars"}}: {{.Stars}}  {{i18n $lang "Forks"}}: {{.Forks}}{{$newLine}}{{i18n $lang "Intro"}}: {{.Synopsis}}" href="/{{.ImportPath}}">{{.ImportPath}}</a>

                                {{if .IsGoRepo}}
                                <span class="label label-info">{{i18n $lang "Standard"}}</span>
                                {{end}}
                            </td>

                            <td>{{.ViewedTime}}</td>
                        </tr>
			            {{end}}
		            </tbody>
		        </table>
		    </div>

		    <div id="user_history" class="tab-pane fade">
		        <h4>
		            <b>{{i18n .Lang "What you have been looking at"}}</b>.
		            <a href="#global_history" class="btn btn-inverse" data-toggle="tab">{{i18n .Lang "Global history"}}</a>
		            <small class="text-info">{{i18n .Lang "Hover link to see more"}}.</small>
		        </h4>

		        <table name="recent_table" class="table table-bordered table-hover">
		            <thead>
		                <tr>
		                    <th>{{i18n .Lang "Import Path"}}</th>
		                    <th>{{i18n .Lang "Viewd Time(Local)"}}</th>
		                </tr>
		            </thead>

		            <tbody>
			            {{range .UserHistory}}
                        <tr>
                            <td>
                                <a title="{{i18n $lang "Refs"}}: {{.RefNum}}  {{i18n $lang "Rank"}}: {{.Rank}}  {{i18n $lang "Views"}}: {{.Views}}{{$newLine}}{{i18n $lang "Issues"}}: {{.Issues}}  {{i18n $lang "Stars"}}: {{.Stars}}  {{i18n $lang "Forks"}}: {{.Forks}}{{$newLine}}{{i18n $lang "Intro"}}: {{.Synopsis}}" href="/{{.ImportPath}}">{{.ImportPath}}</a>

                                {{if .IsGoRepo}}
                                <span class="label label-info">{{i18n $lang "Standard"}}</span>
                                {{end}}
                            </td>

                            <td>{{.ViewedTime}}</td>
                        </tr>
			            {{end}}
		            </tbody>
		        </table>
		    </div>
		</div>
	</div>

	<div class="col-xs-4 col-md-4" style="padding-left: 5px;">
		<div>
			<h4><b>{{i18n .Lang "Announcement"}}</b></h4>
			<p>
                {{if eq .Lang "en-US"}}
				<b>Hacker View</b> provides source file based project code view on the fly for Go Standard Library, Go Subrepo and command line project.
                {{else if eq .Lang "zh-CN"}}
                <b>黑客视图</b> 允许您对 Go 标准库、Go 官方维护库和命令行项目进行基于源文件的即时浏览。
                {{end}}
			</p>
			<a class="btn btn-primary" href="/about">{{i18n .Lang "Learn more"}}</a>
		</div>

		<div>
			<h4><b>{{i18n .Lang "Popular Projects"}}</b></h4>
            <ul class="nav nav-tabs nav-tabs-google">
                <li class="active">
                    <a href="#weekly_stars" data-toggle="tab">{{i18n .Lang "Weekly Stars"}}</a>
                </li>

                <li>
                    <a href="#top_rank" data-toggle="tab">{{i18n .Lang "Top Rank"}}</a>
                </li>

                <li>
                    <a href="#top_views" data-toggle="tab">{{i18n .Lang "Top Views"}}</a>
                </li>
            </ul>

            <div class="tab-content" style="padding-top: 10px;">
                <div id="weekly_stars" class="tab-pane fade active in">
                    <ul name="pop_list" class="unstyled">
                        {{range .WeeklyStarPros}}
                        <li>
                            <span class="badge badge-success">{{.Rank}}</span>
                            <a title="{{i18n $lang "Refs"}}: {{.RefNum}}  {{i18n $lang "Rank"}}: {{.Rank}}  {{i18n $lang "Views"}}: {{.Views}}{{$newLine}}{{i18n $lang "Issues"}}: {{.Issues}}  {{i18n $lang "Stars"}}: {{.Stars}}  {{i18n $lang "Forks"}}: {{.Forks}}" href="/{{.ImportPath}}">{{.ImportPath}}</a>
                        </li>
                        {{end}}
                    </ul>
                </div>

                <div id="top_rank" class="tab-pane fade">
                    <ul name="pop_list" class="unstyled">
                        {{range .TopRankPros}}
                        <li>
                            <span class="badge badge-inverse">{{.Rank}}</span>
                            <a title="{{i18n $lang "Refs"}}: {{.RefNum}}  {{i18n $lang "Rank"}}: {{.Rank}}  {{i18n $lang "Views"}}: {{.Views}}{{$newLine}}{{i18n $lang "Issues"}}: {{.Issues}}  {{i18n $lang "Stars"}}: {{.Stars}}  {{i18n $lang "Forks"}}: {{.Forks}}{{$newLine}}{{i18n $lang "Intro"}}: {{.Synopsis}}" href="/{{.ImportPath}}" href="/{{.ImportPath}}">{{.ImportPath}}</a>
                        </li>
                        {{end}}
                    </ul>
                </div>

                <div id="top_views" class="tab-pane fade">
                    <ul name="pop_list" class="unstyled">
                        {{range .TopViewsPros}}
                        <li>
                            <span class="badge">{{.Views}}</span>
                            <a title="{{i18n $lang "Refs"}}: {{.RefNum}}  {{i18n $lang "Rank"}}: {{.Rank}}  {{i18n $lang "Views"}}: {{.Views}}{{$newLine}}{{i18n $lang "Issues"}}: {{.Issues}}  {{i18n $lang "Stars"}}: {{.Stars}}  {{i18n $lang "Forks"}}: {{.Forks}}{{$newLine}}{{i18n $lang "Intro"}}: {{.Synopsis}}" href="/{{.ImportPath}}" href="/{{..ImportPath}}">{{..ImportPath}}</a>
                        </li>
                        {{end}}
                    </ul>
                </div>
            </div>
		</div>

		<div>
			<h4><b>{{i18n .Lang "Recent Updated Examples"}}</b></h4>
            <ul name="pop_list" class="unstyled">
                {{range .RecentExams}}
                <li>
                    <a href="/{{.Path}}">{{.Path}}</a>
                </li>
                {{end}}
            </ul>
		</div>

	    {{template "home_js"}}
		
		<div>
			<h4><b>{{i18n .Lang "Explore more"}}</b>.</h4>
            <ul class="nav nav-tabs nav-tabs-google">
                <li class="active">
                    <a href="#more_projects" data-toggle="tab">{{i18n .Lang "Projects"}}</a>
                </li>

                <li>
                    <a href="#more_sites" data-toggle="tab">{{i18n .Lang "Sites"}}</a>
                </li>

                <li>
                    <a href="#more_tools" data-toggle="tab">{{i18n .Lang "Tools"}}</a>
                </li>
            </ul>

            <div class="tab-content" style="padding-top: 10px;">
                <div id="more_projects" class="tab-pane fade active in">
                    <ul class="unstyled">
                        <li>
                        	<a href="/index">{{i18n .Lang "Index"}}</a>
                        	- {{i18n .Lang "everything involved"}}
                        </li>

                        <li>
                        	<a href="/search?q=gorepos">{{i18n .Lang "Go Standard Library"}}</a>
                        </li>

                        <li>
                        	<a href="/search?q=gosubrepos">{{i18n .Lang "Go Sub-repositories"}}</a>
                        	- {{i18n .Lang "Developed by Go team"}}
                        </li>

                        <li>
                            <a target="_blank" href="http://godoc.org/">GoDoc</a>
                            - {{i18n .Lang "simple API documentation"}}
                        </li>

                        <li>
                            <a target="_blank" href="http://go-search.org/">Go Search</a>
                            - {{i18n .Lang "even more stuff"}}
                        </li>

                        <li>
                            <a target="_blank" href="https://sourcegraph.com/">Sourcegraph</a>
                            - {{i18n .Lang "powerful usage analyzer"}}
                        </li>

                        <li>
                        	<a target="_blank" href="https://code.google.com/p/go-wiki/wiki/Projects">Projects @ go-wiki</a>
                        </li>
                    </ul>
                </div>

                <div id="more_sites" class="tab-pane fade">
                    <ul class="unstyled">
                        <li>
                        	<a target="_blank" href="http://bbs.go-china.org">{{i18n .Lang "Go China Community"}}</a>
                        </li>

                        <li>
                            <a target="_blank" href="https://gobyexample.com/">Go by Example</a>
                        </li>

                        <li>
                            <a target="_blank" href="http://godaily.org/">Go Daily</a>
                            － Go 语言每日一练
                        </li>

                        <li>
                            <a target="_blank" href="http://gorevel.cn/">Revel 社区</a>
                        </li>

                        <li>
                        	<a target="_blank" href="http://golangtc.com">Golang 中国</a>
                        	－ Go 语言交流学习论坛
                        </li>

                        <li>
                            <a target="_blank" href="http://sudochina.com">速动中国</a>
                            - Go 语言技术分享博客站
                        </li>

                        <li>
                            <a target="_blank" href="http://edu.go-china.org">Go China 网络课堂</a>
                            - Go 语言在线教育基地
                        </li>
                    </ul>
                </div>

                <div id="more_tools" class="tab-pane fade">
                    <ul class="unstyled">
                        <li>
                            <a target="_blank" href="https://github.com/gpmgo/gopm">gopm</a>
                            - {{i18n .Lang "Go Package Manager"}}
                        </li>
                        
                        <li>
                            <a target="_blank" href="http://gobuild.io">Go Build</a>
                            - {{i18n .Lang "online Go compiler"}}
                        </li>
                        
                        <li>
                            <a target="_blank" href="http://regoio.herokuapp.com/">Rego</a>
                            - {{i18n .Lang "online Go regular expression tester"}}
                        </li>

                        <li>
                            <a target="_blank" href="https://github.com/visualfc/liteide">LiteIDE</a>
                            - {{i18n .Lang "the best IDE for Go development"}}
                        </li>
                    </ul>
                </div>
            </div>
		</div>
	</div>
</div>
{{end}}

{{define "home_js"}}
<script>
    (function () {
        var tables = document.getElementsByName("recent_table");
        var now = new Date();
        for (var n = 0; n < tables.length; n++) {
            var table = tables[n];
            var items = table.getElementsByTagName("tr");
            for (var i = 1; i < items.length; i++) {
                // Limit length.
                var s = table.rows[i].cells[0].getElementsByTagName("a")[0];
                if (s.innerHTML.length > 45) {
                    s.innerHTML = "..." + s.innerHTML.substr(s.innerHTML.length - 42);
                }
                // Convert timestamp to local time.
                var t = parseInt(table.rows[i].cells[1].innerHTML);
                var d = new Date(t * 1000);
                table.rows[i].cells[1].innerHTML = d.toLocaleString();
            }
        }
    })();

    (function () {
        var lists = document.getElementsByName("pop_list");
        var now = new Date();
        for (var n = 0; n < lists.length; n++) {
            var list = lists[n];
            var items = list.getElementsByTagName("li");
            for (var i = 0; i < items.length; i++) {
                // Limit length.
                var s = items[i].getElementsByTagName("a")[0];
                if (s.innerHTML.length > 40) {
                    s.title="Path: "+ s.innerHTML+"\n"+ s.title;
                    s.innerHTML = "..." + s.innerHTML.substr(s.innerHTML.length - 37);
                }
            }
        }
    })();
</script>
{{end}}